﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BusinessHanler;

namespace BusinessHandler
{
    public class NewsCommentController : NewsDataClassesDataContext
    {
        private static NewsCommentController instance;
        public static NewsCommentController Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new NewsCommentController();
                }
                return instance;
            }
            set
            {
                instance = value;
            }
        }
        public bool Delete(int id)
        {
            NewsDataClassesDataContext dataContext = new NewsDataClassesDataContext();
            NewsComment item = (from o in dataContext.NewsComments
                                   where o.CommentTitleID == id select o ).SingleOrDefault();
            if(item!=null)
            {
                try
                {
                    dataContext.NewsComments.DeleteOnSubmit(item);
                    dataContext.SubmitChanges();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            return false;
        }
    }
}